<h1>Review List for Virginia</h1>

<h3>Effective October, 2012</h3>
<script>
	$(document).ready(function(){
		$("#reset").bind("click", function (){
			$("#search_field").val("");
		$("#status").addClass(this.text());
		});
		 $("#search_field" ).autocomplete({
			source: birdArray
		});
		
		$("#birdTableBody").sortable({
			
		});
	
	});
	
	  var birdArray = <%= @birds.map(&:common_name).sort.to_json.html_safe %>;

	
</script>

<% if flash[:notice] %>
	<div id="notice" ><%= flash[:notice] %></div>
<% end %>
<p>The following species, field-identifiable superspecies/subspecies, and color morphs have already been documented and accepted in the Commonwealth of Virginia and are reviewable statewide except as indicated.</p>

<p>Eastern Coastal Plain is defined as the following counties/cities: Accomack, Chesapeake, Gloucester, Hampton, Lancaster, Mathews, Middlesex, Newport News, Norfolk, Northampton, Northumberland, Poquoson, Portsmouth, Richmond County, Suffolk, Virginia Beach, Westmoreland.</p>

<%= form_tag birds_path, :method => 'get' do %>
     <%= text_field_tag :search, params[:search], :id => 'search_field'	 %>
     <%= submit_tag "Search", :class=>"btn-custom",:name => nil %> 
	 <input type ="button" class="btn-custom" value="Reset" id="reset"/>
<% end %> 

<% if params[:search] %>
	  <%= link_to "Show All", birds_path, :method => :get  %><br />
<% end %> 


<% if isadmin? %>
 <%= link_to "Reorder Birds List", reorder_birds_path %>
<% end %>

<table id="birdTable">
 <thead>
  <tr>
	<% if isadmin? %>
		<th>ID</th>
		<th>Position</th>
	<% end %>
    <th>Common name</th>
    <th>Reviewable</th>
	<th>Exceptions</th>

	<% if isadmin? %>
		<th></th>
		<th></th>
		<!-- Third column removed - we don't want 'destroy'<th></th>-->
		<th>Toggle Reviewable</th><!-- New third column: toggle reviewable -->
	<% end %>
  </tr>
</thead>
<tbody id="birdTableBody">
<% @birds.each do |bird| %>
  <tr class="subRow">
	<% if isadmin? %>
		<td><%= bird.id %></td>
		<td><%= bird.position%></td>
		
	<% end %>
    <% if bird.id != 31 || isadmin? %>
		<td><%= link_to bird.common_name, bird %></td>
		<td class="<%= bird.reviewable %>"><%= bird.reviewable.humanize %></td>
	<% end %>
		<td ><%= bird.region %></td>
	<% if isadmin? %>
		<td><%= link_to 'Show', bird %></td>
		<td><%= link_to 'Edit', edit_bird_path(bird) %></td>
		<!--No longer allowing 'destroy'<td><%= link_to 'Destroy', bird, confirm: 'Are you sure?', method: :delete %></td>-->
		<td><%= link_to 'Toggle', toggle_bird_path(bird) %></td>
	<% end %>
  </tr>
<% end %>
</tbody>
</table>

<br />

<%= if isadmin? 
	link_to 'New Bird', new_bird_path 
	end %>
